<?php
namespace app\api\controller;
use app\common\controller\Api;

class File
{
    public function upload()
    {
        $file = request()->file('file');
        $path = 'uploads/' . 'pets/' . date('Ymd');
	    $info = $file->rule('uniqid')->validate(['size' => 5242880])->move(ROOT_PATH . 'web/' . $path);
	    if($info){
	        // 成功上传后 获取上传信息
	        return json(['code' => 1, 'file' => config('web_site_url') . '/' . $path . '/' . $info->getSaveName()]);
	    }else{
	        return json(['code' => 0, 'error' => $file->getError()]);
	    }
    }

}
